/*
 * @Description: 系统异常状态
 * @Author: xinqiao lxq1990.0716@qq.com
 * @Date: 2023-03-27
 * @LastEditors: xinqiao lxq1990.0716@qq.com
 * @LastEditTime: 2023-03-30 12:08:40
 */

import { defineStore } from 'pinia'
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'

import { ExceptionEnum } from '/@/enums/exceptionEnum'

export const useExceptionStore = defineStore('exception', () => {
  const status = ref<ExceptionEnum>(ExceptionEnum.SUCCESS)

  const route = useRoute()
  watch(route, () => {
    if (status.value !== ExceptionEnum.SUCCESS) {
      status.value = ExceptionEnum.SUCCESS
    }
  })
  return { status }
})
